package com.cg.common;

import lombok.*;

@NoArgsConstructor
@AllArgsConstructor
@ToString
@Setter
@Getter
public class Result<T> {
    private Integer code; // 200成功，其它失败
    private String message;
    private T data;

    public static <T> Result<T> success(T data) {
        Result<T> r = new Result<>();
        r.code = 200;
        r.data = data;
        return r;
    }

    public static <T> Result<T> success(T data, String msg) {
        Result<T> r = new Result<>();
        r.code = 200;
        r.data = data;
        r.message = msg;
        return r;
    }

    public static <T> Result<T> error(String msg) {
        Result<T> r = new Result<>();
        r.code = 500;
        r.message = msg;
        return r;
    }
}


